
<div class="page-toolbar">
    <!-- <div class="page-filter fr">
        <form class="layui-form layui-form-pane" action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索</label>
            <div class="layui-input-inline">
                <input type="text" name="keyword" lay-verify="required" placeholder="输入关键词搜索" class="layui-input">
            </div>
        </div>
        </form>
    </div> -->
    <div class="layui-btn-group fl">
        <a href="{:url('add')}" class="layui-btn layui-btn-primary layui-icon layui-icon-add-circle-fine hisi-iframe-pop">&nbsp;转账</a>
        <button type="button" class="layui-btn layui-btn-warm layui-icon layui-icon-download-circle export">导出</button>
        <!-- <a data-href="{:url('status?val=1')}" class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-play" data-table="dataTable">&nbsp;启用</a>
        <a data-href="{:url('status?val=0')}" class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-pause" data-table="dataTable">&nbsp;禁用</a>
        <a data-href="{:url('del')}" class="layui-btn layui-btn-primary j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a> -->
    </div>
</div>
<table id="dataTable"></table>
{include file="system@block/layui" /}
<script type="text/html" id="statusTpl">
    {{# if(d.id != 0){  }}
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="正常|关闭" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('status')}?id={{ d.id }}">
    {{# } }}
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    {{# if(d.id != 0){  }}
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe-pop">修改</a>
    <a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>

    {{# } }}
</script>
<script type="text/javascript">
    layui.use(['table','jquery','excel'], function() {
        var table = layui.table;
        var $ = layui.jquery;
        var excel = layui.excel;
        $(document).on('click','.export',function(){
            var form = $('#hisi-table-search').serializeArray();
            var where = new Array();
            form.push({name:'type',value:2});
            $.ajax({
               url: '{:url()}',
               data:form,
               dataType: 'json',
               success: function(res) {
                   // 假如返回的 res.data 是需要导出的列表数据
                   console.log(res.data);// [{name: 'wang', age: 18, sex: '男'}, {name: 'layui', age: 3, sex: '女'}]
                   // 1. 数组头部新增表头
                   res.data.unshift({a_account_text: '转出账户',b_account_text:'转入账户',price:'金额',bak:'备注',createtime:'添加时间'});
                   // 2. 如果需要调整顺序，请执行梳理函数
                   var data = excel.filterExportData(res.data, [
                       'a_account_text',
                       'b_account_text',
                       'price',
                       'bak',
                       'createtime'
                   ]);
                   // 3. 执行导出函数，系统会弹出弹框
                   excel.exportExcel({
                       sheet1: data
                   }, '银行转账.xlsx', 'xlsx');
               }
           });
        })
        table.render({
            elem: '#dataTable'
            ,url: '{:url('', input('get.'))}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '暂无相关数据'
            }
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'a_account_text', title: '转出账户'}
                ,{field: 'b_account_text', title: '转入账户'}
                ,{field: 'price', title: '金额'}
                ,{field: 'bak', title: '备注'}
                ,{field: 'createtime', title: '添加时间'}
            ]]
        });
    });
</script>
